package Day6.ZuoYe.Market;

import java.util.Scanner;

public class MarketTest {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Market m = new Market();
        m.setName("永辉超市");
        m.setAddress("合肥长江路188号");
        while (true) {
            System.out.println("1.开卡；2.积分累计；3.积分兑换；4.查询剩余积分；5.修改密码；0.退出");
            int a = input.nextInt();
            if (a == 1) {
                System.out.println("*****开卡*****");
                System.out.println("请输入会员号：");
                String no = input.next();
                System.out.println("请输入姓名：");
                String name = input.next();
                System.out.println("请输入手机号：");
                String phone = input.next();
                System.out.println("请输入初始积分：");
                int jf = input.nextInt();
                System.out.println("请设置密码：");
                String mm = input.next();
                Vip v = new Vip(no,name,phone,jf,mm);
                if(m.addVip(v)){
                    System.out.println("会员办理成功！");
                }else {
                    System.out.println("会员已存在，办理失败！");
                }
            } else if (a == 2) {
                System.out.println("*****积分累计*****");
                System.out.println("请输入会员卡号：");
                String no=input.next();
                System.out.println("请输入本次增加的积分：");
                int jf = input.nextInt();
                if(m.addJifen(no,jf)){
                    System.out.println("积分添加成功！");
                }else {
                    System.out.println("会员账号错误，积分添加失败！");
                }
            } else if (a == 3) {
                System.out.println("*****积分兑换*****");
                System.out.println("请输入会员号：");
                String vipNo=input.next();
                System.out.println("请输入密码：");
                String mm=input.next();
                System.out.println("请选择需要兑换的礼品：");
                System.out.println("选择兑换的礼品：1：100分兑换餐巾纸一包；\n    2：400分兑换剃须刀一把；" +
                        "\n 3：1000分兑换炒锅一个；");
                int choose=input.nextInt();
                if (m.cash(vipNo,mm,choose)) {
                    System.out.println("兑换成功！");
                }else {
                    System.out.println("兑换失败！");
                }
            } else if (a == 4) {
                System.out.println("*****查询剩余积分*****");
                m.showVip();
            } else if (a == 5) {
                System.out.println("*****修改密码*****");
                System.out.println("请输入会员号：");
                String vipNo=input.next();
                System.out.println("请输入密码：");
                String mm=input.next();
                System.out.println("请输入新密码：");
                String xmm=input.next();
                System.out.println("请再次输入新密码：");
                String xxmm=input.next();
                if (xmm.equals(xxmm)) {
                    if (m.xiuGai(vipNo,mm,xmm)) {
                        System.out.println("密码修改成功！");
                    }else {
                        System.out.println("会员账号或者旧密码不正确，修改失败！");
                    }
                }else {
                    System.out.println("2次新密码输入不一样，修改失败！");
                }
            } else {
                System.out.println("*****退出*****");
                return;
            }
        }
    }
}
